package webExperiment;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;

import javax.swing.BorderFactory;
import javax.swing.JPanel;
import javax.swing.JTextArea;

//-----------------------------------------------------
public class SelectionQuestion extends JPanel {
    /**
	 * 
	 */
    private static final long serialVersionUID = 1L;
    private JTextArea quest = new JTextArea();
    public MultipleChoice mc;

    public static int QuestWidth = 280;
    public static int Width = 500;
    public static int Defautheight = 40;
    public static int HGap = 1;

    public SelectionQuestion(int theNoChoices, Color bgColor, int LabelWidth,
	    boolean createLineBorder) {
	mc = new MultipleChoice(theNoChoices, bgColor, HGap, LabelWidth);
	// set muliple choice
	// mc.setSize(new Dimension(160,25));

	this.setBackground(bgColor);
	this.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 5));
	this.setPreferredSize(new Dimension(Width, Defautheight));
	if (createLineBorder)
	    this.setBorder(BorderFactory.createLineBorder(Color.lightGray));

	quest.setPreferredSize(new Dimension(QuestWidth, Defautheight - 10));
	quest.setEditable(false);
	quest.setLineWrap(true);
	quest.setWrapStyleWord(true);
	quest.setFont(new Font("Arial", Font.BOLD, 12));
	quest.setBackground(bgColor);
	quest.setForeground(Color.black);

	this.add(quest);
	this.add(mc);
    }

    public void setQuestion(String questStr) {
	quest.setText(questStr);
	mc.reset(0);
    }

    public boolean setSelectionLabels(int idx, String text) {
	return mc.setLabel(idx, text);
    }

    public int getSelectedItem() {
	return mc.getSelectedItem();
    }

    public void setQuestionColor(Color fg) {
	quest.setForeground(fg);
    }

    public void setQuestionActive(boolean flag) {
	if (flag) {
	    quest.setForeground(Color.BLACK);
	    mc.setVisible(true);
	} else {
	    quest.setForeground(Color.LIGHT_GRAY);
	    mc.setVisible(false);
	}
    }

}// end class (long)
